package com.sergio.compress.cp.base;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

/**
 * @Author : Sergio.D
 * @Description :
 * @CreateDate ：2023/6/14 17:48
 */
@Data
public class TestSource {

    String filePath;

    int sourceLength;

    byte[] sourceData;

    public TestSource(String filePath) throws IOException {
        this.filePath = filePath;
        File file = new File(filePath);
        if (file.exists()) {
            sourceData = Files.readAllBytes(file.toPath());
            sourceLength = sourceData.length;
        } else {
            throw new RuntimeException("文件不存在 : " + filePath);
        }
    }
    public TestSource(byte[] source) throws IOException {
            sourceData = source;
            sourceLength = sourceData.length;
    }

}
